package com.buddy.rpc.provider;

import com.buddy.rpc.api.HelloService;
import com.buddy.rpc.provider.service.HelloServiceImpl;
import com.buddy.rpc.sdk.framework.Url;
import com.buddy.rpc.sdk.http.HttpServer;
import com.buddy.rpc.sdk.register.RemoteRegister;
import com.buddy.rpc.sdk.register.ServiceRegister;

/**
 * @author buddy
 * @date 2021/12/21
 */
public class Provider {

    public static void main(String[] args) {
        // 1. 暴露服务
        // {服务名:实现类}
        System.out.println("暴露服务====== service:"+ HelloService.class.getName()+"-------> impl:"+ HelloServiceImpl.class);
        ServiceRegister.register(HelloService.class.getName(),HelloServiceImpl.class);

        // 2.远程注册{服务名:实现类} {服务名:List(url)}
        Url url = new Url("localhost",8080);
        RemoteRegister.register(HelloService.class.getName(),url);

        // 3. 启动tomcat
        HttpServer httpServer = new HttpServer();
        httpServer.start("localhost",8080);

    }
}
